package tx.bj12320.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import tx.bj12320.model.OrgInfo;
import tx.bj12320.model.UserInfo;
import tx.bj12320.model.enums.SysUserTypeEnum;
import tx.bj12320.service.UserInfoManager;
import tx.bj12320.util.Struts2Utils;
import tx.bj12320.vo.query.CalendarInfo;
import javacommon.base.BaseStruts2Action;

public class CalendarAction extends BaseStruts2Action{
	public String calendar(){
		return "/calendar.jsp";
	}
	public String outCalendarInfo(){
		List<UserInfo> ul=userInfoManager.findAllBySysUserType(SysUserTypeEnum.BJ12320.getCode());

		List l=new ArrayList();
		int i=0;
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		for (UserInfo ui : ul) {
			CalendarInfo ci=new CalendarInfo();
			ci.setTitle(ui.getRealName());
			Calendar cal=Calendar.getInstance();
			cal.add(Calendar.DATE,i);
			ci.setStart(df.format(cal.getTime()));
			l.add(ci);
			i++;
		}
		Struts2Utils.renderJson(l);
		return null;
	}
	private UserInfoManager userInfoManager;
	public void setUserInfoManager(UserInfoManager manager) {
		this.userInfoManager = manager;
	}
}
